package nu.mine.tbje.easyEDT;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Iterator;
import java.util.List;

import nu.mine.tbje.easyEDT.data.Cours;

import junit.framework.TestCase;

public class EdtTest extends TestCase {

	public void testFunction(){
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(new Date());
		System.out.println(calendar.get(Calendar.WEEK_OF_YEAR));
		Edt edt = new Edt();
		edt.setLogin("adeweb");
		edt.setPass("ade423");
		edt.doLogin();
		try {
			edt.doInit();
		} catch (Exception e1) {
			e1.printStackTrace();
		}
		
		edt.setIdAndCat("trainee", 368);
		Calendar cal = Calendar.getInstance();
		Date date = cal.getTime();

		edt.setDisplayOptions();
		edt.setWeek(cal.get(Calendar.WEEK_OF_YEAR));
		try {
			InputStream i = edt.getData();
			BufferedReader reader = new BufferedReader(new InputStreamReader(i));
			String x = null;
			while ((x = reader.readLine()) != null){
				System.out.println(x);
			}
			Iterator<Cours> iterator = edt.parse(i).iterator();
			Cours cours = null;
			while (iterator.hasNext()){
				cours = iterator.next();
				System.out.println(cours.getName());
				System.out.println(cours.getDate());
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
//		edt.setDisplayOptions();
//		edt.setWeek(calendar.get(Calendar.WEEK_OF_YEAR)+1);
//		try {
//			InputStream i = edt.getData();
//			Iterator<Cours> iterator = edt.parse(i).iterator();
//			Cours cours = null;
//			while (iterator.hasNext()){
//				cours = iterator.next();
//				System.out.println(cours.getName());
//				System.out.println(cours.getDate());
//			}
//		} catch (Exception e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}

	}
	
	public void testWriter(){
	}
}
